import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

const aboutOption = {
  namespaced: true,
  state: {
    counter: 0,
    name: 'zhangsan'
  },
  getters: {
    mul(state) {
      return state.counter * 2
    }
  },
  mutations: {
    jiaM(state) {
      state.counter++;
    },
    jianM(state, val) {
      state.counter -= val;
    }
  },
  actions: {
    jiaA(content) { //上下文
      content.commit('jiaM');
    },
    jianA(content, val) {
      content.commit('jianM', val);
    }
  }
}

const homeOption = {
  namespaced: true,
  state: {
  },
  getters: {},
  mutations: {
    editNameM(state, val) {
      state.name = val
    }
  },
  actions: {
    editNameA(content, val) {
      content.commit('editNameM', val);
    }
  }
}
export default new Vuex.Store({
  modules: {
    // aboutOption: aboutOption,
    // homeOption: homeOption
    aboutOption,
    homeOption
  }
})
